---
title: "NetlifyDeployer | Deployment"
description: "Learn how to deploy a Mastra application to Netlify using the Mastra NetlifyDeployer"
---

# NetlifyDeployer

The `NetlifyDeployer` class handles deployment of standalone Mastra applications to Netlify. It manages configuration, deployment, and extends the base [Deployer](/reference/v1/deployer/) class with Netlify specific functionality.

## Installation

```bash copy
npm install @mastra/deployer-netlify@beta
```

## Usage example

```typescript title="src/mastra/index.ts" copy
import { Mastra } from "@mastra/core";
import { NetlifyDeployer } from "@mastra/deployer-netlify";

export const mastra = new Mastra({
  deployer: new NetlifyDeployer(),
});
```

> See the [NetlifyDeployer](/reference/v1/deployer/netlify) API reference for all available configuration options.

## Continuous integration

After connecting your Mastra project’s Git repository to Netlify, update the project settings. In the Netlify dashboard, go to **Project configuration** > **Build & deploy** > **Continuous deployment**, and under **Build settings**, set the following:

- **Build command**: `npm run build` (optional)

### Environment variables

Before your first deployment, make sure to add any environment variables used by your application. For example, if you're using OpenAI as the LLM, you'll need to set `OPENAI_API_KEY` in your Netlify project settings.

> See [Environment variables overview](https://docs.netlify.com/environment-variables/overview/) for more details.

Your project is now configured with automatic deployments which occur whenever you push to the configured branch of your GitHub repository.

## Manual deployment

Manual deployments are also possible using the [Netlify CLI](https://docs.netlify.com/cli/get-started/). With the Netlify CLI installed run the following from your project root to deploy your application. You can also run `netlify dev` from your project root to test your Mastra application locally.

```bash copy
netlify deploy --prod
```

:::warning

When using `netlify deploy` instead of continuous deployment, you need to create a `netlify.toml` file with these contents:

```toml
[build]
  command = "npm run build"
  publish = ".netlify/v1/functions"

[functions]
  directory = ".netlify/v1/functions"
  node_bundler = "none"
  included_files = [".netlify/v1/functions/**"]

[[redirects]]
  from = "/*"
  to = "/.netlify/functions/api/:splat"
  status = 200

[build.environment]
  NODE_VERSION = "22.13.0"
```

Adjust the `build.command` to your project.

:::

## Build output

The build output for Mastra applications using the `NetlifyDeployer` includes all agents, tools, and workflows in your project, along with Mastra-specific files required to run your application on Netlify.

```bash
your-project/
└── .netlify/
    └── v1/
        ├── config.json
        └── functions/
            └── api/
                ├── index.js
                ├── package.json
                └── node_modules/
```

The `NetlifyDeployer` automatically generates a `config.json` configuration file in `.netlify/v1` with the following settings:

```json
{
  "functions": {
    "directory": ".netlify/v1/functions",
    "node_bundler": "none",
    "included_files": [".netlify/v1/functions/**"]
  },
  "redirects": [
    {
      "force": true,
      "from": "/*",
      "to": "/.netlify/functions/api/:splat",
      "status": 200
    }
  ]
}
```

## Next steps

- [Mastra Client SDK](/reference/v1/client-js/mastra-client)
